home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / HENSA / MISC / SHELL.ARC / Shell / Sources / c / Printf < prev    next >
Text File  |  1994-08-01  |  2KB  |  76 lines

  1. #include <stdarg.h>
  2. #include <string.h>
  3. #include <ctype.h>
  4.  
  5. #include "DeskLib:Event.h"
  6.  
  7. #include "Shell.SafeAlloc.h"
  8. #include "Shell.TextRect.h"
  9. #include "Shell.Printf.h"
  10.  
  11.  
  12.  
  13. void    Shell_Printf( const char *fmt, ...)
  14. {    va_list args;
  15. va_start( args, fmt);
  16. vsprintf( Shell_string, fmt, args);
  17. va_end( args);
  18. Shell_TextRectPrint( NULL, Shell_string);
  19. }
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28. static BOOL Shell_WaitPrintfNullHandler( event_pollblock *event, void *reference)
  29. {
  30. UNUSED( event);
  31. Shell_TextRectPrint( NULL, (char *) reference);
  32. Event_Release( event_NULL, event_ANY, event_ANY, Shell_WaitPrintfNullHandler, reference);
  33. free( reference);
  34. return TRUE;
  35. }
  36.  
  37.  
  38.  
  39.  
  40. void    Shell_WaitPrintf( const char *fmt, ...)
  41.     /* You can call this anytime, even inside a redraw function.    */
  42. {    va_list args;
  43.     char    *text;
  44.  
  45. va_start( args, fmt);
  46. vsprintf( Shell_string, fmt, args);
  47. va_end( args);
  48.  
  49. text = Shell_SafeMalloc( 1 + strlen( Shell_string));
  50. strcpy( text, Shell_string);
  51.  
  52. Event_Claim( event_NULL, event_ANY, event_ANY, Shell_WaitPrintfNullHandler, (void *) text);
  53.     /* Shell_WaitPrintfNullHandler will Event_Release itself when it is called and then     */
  54.     /* free the malloc-ed memoy 'text', so the data gets printed just once.            */
  55.     /* Isn't Event_* wonderful ?                                */
  56. }
  57.  
  58.  
  59.  
  60. void    Shell_SafeWaitPrintf( const char *fmt, ...)
  61. {    va_list args;
  62.     char    *text, *c;
  63.  
  64. va_start( args, fmt);
  65. vsprintf( Shell_string, fmt, args);
  66. va_end( args);
  67.  
  68. text = Shell_SafeMalloc( 1 + strlen( Shell_string));
  69. strcpy( text, Shell_string);
  70.  
  71. for ( c=text; *c; c++)    if ( iscntrl(*c) && *c!='\n' && *c!='\0')    *c = '¤';
  72.  
  73. Event_Claim( event_NULL, event_ANY, event_ANY, Shell_WaitPrintfNullHandler, (void *) text);
  74. }
  75.  
  76.